<div id="tiga_ba">
	<div id="tiga_baa">Data Jaminan </div>
	<div id="tiga_bab">
		<a href="javascript:void(0)" onClick="location.href='utama.php?module=mod_jaminan&view=tabel_tambah'">
			<button class="button">Tambah</button>
		</a>
	</div>
	<div class="clear"></div>
</div>

<?php
	if(!empty($_GET['nama'])){
		$param_nama=$_GET['nama'];
		$jenis=$_GET['jenis'];
	}else{
		$param_nama=$_POST['nama'];
		$jenis=$_POST['jenis_cari'];
	}

?>

<table style="margin-left: 5px;" width="880" >
	<tr>
		<form method=post action='utama.php?module=mod_peserta'>
		<td width="65">Pencarian  : </td>
		<td width="200"><input type="text" name="nama" value="<?php echo $param_nama; ?>" class="input_field" /></td>
		<td><input name="submit" type="submit" class="button" value="Cari" /></td>
		</form>
		<!--<td align="right"><a href="module/mod_jaminan/cetak_jaminan.php"><img src="asset/images/print.png" width="30"></a></td>-->
	</tr>
</table>

<table class="tabel">
	<tr>
		<th>NO</th>
		<th>Aksi</th>
		<th>ID Jaminan</th>
		<th>ID Peserta</th>
		<th>Nama</th>
		<th>Tempat, Tanggal Lahir</th>
		<th>Jenis Peserta</th>
		<th>Tgl Mulai</th>
		<th>Tgl Selesai</th>
		<th>ID Lama</th>
	</tr>
	<?php
		$p= new paging ;
		$batas= 10;

		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		$sql="select id_jaminan, p.id_peserta, nama, tempat_lahir, tgl_lahir, jenis_peserta, ja.tgl_mulai,ja.tgl_selesai, id_jaminan_sebelumnya from jaminan ja inner join peserta p on ja.id_peserta = p.id_peserta inner join penduduk pn on p.id_penduduk = pn.id_penduduk inner join jenis_peserta j on p.id_jenis_peserta = j.id_jenis_peserta where p.id_peserta like '%$param_nama%' order by ja.id_jaminan desc limit $posisi,$batas";
		//echo $sql;
		$qry=mysql_query($sql);
		$no=$posisi + 1;
		if(mysql_num_rows($qry)>0){
		
			while($hasil=mysql_fetch_array($qry)){
				$jenis = mysql_num_rows(mysql_query("select j.id_jaminan from jaminan j inner join jaminan_ritl jr on jr.id_jaminan = j.id_jaminan where j.id_jaminan = '$hasil[id_jaminan]'"));
				if($jenis > 0){
					$jns = 2;
				}else{
					$jns = 1;
				}
	?>
				<tr>
					<td align="center" width="30"><?php echo $no;?></td>
					<td align="center" width="60">
						<a href="module/mod_jaminan/print.php?id=<?php echo "$hasil[id_jaminan]&jns=$jns";?>">
						<img src="asset/images/print.png" width="14" target="_BLANK"></a>
						<?php
						if($_SESSION['id_ppk'] == '0'){
						?>
						<a href="utama.php?module=mod_jaminan&view=form_edit&id=<?php echo $hasil['id_jaminan'];?>"><img src="asset/images/edit.png" title="Ubah Data"></a>
						<a href="utama.php?module=mod_jaminan&act=hapus&id=<?php echo $hasil['id_jaminan'];?>" onclick="return confirm('Anda yakin ingin Menghapus Data ?')"><img src="asset/images/delete.png" title="Hapus Data"></a>
						<?php } ?>
					</td>
					<td align="center" ><?php echo $hasil['id_jaminan'];?></td>
					<td align="center" ><?php echo $hasil['id_peserta'];?></td>
					<td ><?php echo $hasil['nama'];?></td>
					<td ><?php echo $hasil['tempat_lahir'].", ".tgl_ind1("$hasil[tgl_lahir]");?></td>
					<td align="center"><?php echo $hasil['jenis_peserta'];?></td>
					<td align="center"><?php echo tgl_ind1("$hasil[tgl_mulai]");?></td>
					<td align="center"><?php echo tgl_ind1("$hasil[tgl_selesai]");?></td>
					<td align="center"><?php echo $hasil['id_jaminan_sebelumnya'];?></td>
				</tr>
				
		<?php
				$no++;
			}
		}else{
		?>
	
	<tr>
		<td colspan="11" align="center">Data tidak Ada </td>
	</tr>
	
	<?php
		}
	?>
</table>

<?php
	$sql2="select id_jaminan, p.id_peserta, nama, tempat_lahir, tgl_lahir, jenis_peserta, ja.tgl_mulai,ja.tgl_selesai, id_jaminan_sebelumnya from jaminan ja inner join peserta p on ja.id_peserta = p.id_peserta inner join penduduk pn on p.id_penduduk = pn.id_penduduk inner join jenis_peserta j on p.id_jenis_peserta = j.id_jenis_peserta where p.id_peserta like '%$param_nama%'" ;
	$query2=mysql_query($sql2);
	$jumlah_data=mysql_num_rows($query2);
	//dapatkan jumlah halaman
	$jumlah_halaman= $p->jumlahhalaman($jumlah_data,$batas);
	//cetak link
	$linkhalaman=$p->navhalaman($_GET['halaman'],$jumlah_halaman,$_SERVER['PHP_SELF']."?module=mod_jaminan","nama=$param_nama");
	print($linkhalaman);
?>
        